<?php
require('../configs/include.php');
require(C_FULL_PATH . 'modules/m_phpass/PasswordHash.php');

class c_ingresar_empleado extends super_controller {

     public function mostrardatos() {
         $datos = array();
         $datos['Nombre Empleado']=$this->post->nombreEmple;
         $datos['Contraseña']=$this->post->password;
         $datos['Cargo']=$this->post->cargo;
         $datos['Fecha de nacimiento']=$this->post->fenacimiento;
         $datos['Cedula']=$this->post->cedula;
         for ($i = 1; $i <= 2; $i++) {
             $var='sexo'.$i;
             $tmp=$this->post->$var;
             if(isset($tmp)){
                $datos['Sexo']=$tmp;
             }
        }
         $this->engine->assign('Empleado',$datos );


    }
    public function registrar(){
        $empleado = new empleado($this->post);
        
            $options = "normal";
            $this->orm->connect();
            $this->orm->insert_data($options, $empleado);
            $this->orm->close();

            $this->type_warning = "success";
            $this->msg_warning = "Register added satisfactory, you can login Now!";
            $this->engine->assign('type_warning', $this->type_warning);
            $this->engine->assign('msg_warning', $this->msg_warning);
            $this->temp_aux = 'message.tpl';
        
    }
    public function display() {
        $this->engine->assign('title', 'Ingresar Empleado');
        $this->engine->display('header.tpl');
         if ($this->error == 1) {
            $this->engine->assign('obj', $this->post);
            $this->engine->assign('type_warning', $this->type_warning);
            $this->engine->assign('msg_warning', $this->msg_warning);
            $this->temp_aux = 'message.tpl';
        }
         $this->engine->display($this->temp_aux);
        $this->engine->display('ingresar_empleado.tpl');
        $this->engine->display('footer.tpl');
    }

    public function run() {
        try {
            if (isset($this->get->option)) {
                $this->{$this->get->option}();
            }
        } catch (Exception $e) {
            $this->error = 1;
            $this->msg_warning = $e->getMessage();
        }
        $this->display();
    }

}

$call = new c_ingresar_empleado();
$call->run();
?>
